package com.teradata.olingo.task;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Component;

import java.util.Random;
import java.util.concurrent.Future;

/**
 * @Project: cmcchq
 * @Description:
 * @Version 1.0
 * @Throws :
 * @Author: <li>2019/5/7 lyndon Create 1.0
 * @Copyright (c)2019-2019 版权所有
 * @Modified By:
 */
@Slf4j
@Component
public class Task {
//    public static Random random = new Random();

    @Async("taskExecutor")
    public Future<String> run() throws Exception {
        log.info("Task running by {}", Thread.currentThread().getName());
//        long sleep = random.nextInt(10000);
//        log.info("开始任务，需耗时：" + sleep + "毫秒");
//        Thread.sleep(sleep);
        Thread.sleep(1000);
        log.info("完成任务{}", Thread.currentThread().getName());
        return new AsyncResult<>("test");
    }
}
